import { fetchGet, fetchPost, fetchPut } from "~/request/request";
import { REP } from "~/api/common";
import {
  IPostDetails,
  IPostListParams,
  IUpdatePostParams,
  PostListResult,
  SendNewPostParams,
} from "~/api/post/types";

export const fetchGetPostList = (
  params: IPostListParams
): Promise<REP<PostListResult>> => fetchGet(`/post/list`, params);

export const fetchSendNewPost = (
  params: SendNewPostParams
): Promise<REP<null>> => fetchPost(`/post/send`, params);

export const fetchGetPostDetails = (
  post_id: string
): Promise<REP<IPostDetails>> => fetchGet(`/post/${post_id} `);

export const fetchPostUpdate = (
  params: IPostDetails
): Promise<REP<null>> => fetchPut(`/post/update`, params);
